package com.changgou.order.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.goods.pojo.Sku;
import com.changgou.order.config.TokenDecode;
import com.changgou.order.service.MyCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mycollection")
public class MyCollectionController {
    @Autowired
    private TokenDecode tokenDecode;
    @Autowired
    private MyCollectionService myCollectionService;

    @GetMapping("/listmycollection")
    public Result listCollection(){
        String username = tokenDecode.getUserInfo().get("username");
        List<Sku> skus = myCollectionService.findByUsername(username);
        return new Result(true,StatusCode.OK,"查询成功",skus);
    }
}
